﻿Public Class Utility

    Public Shared Function EpochToDate(MilliSeconds As Long) As Date

        If MilliSeconds >= 0 Then
            Return CDate("1.1.1970 00:00:00").AddMilliseconds(MilliSeconds)
        Else
            Return CDate("1.1.1970 00:00:00")
        End If

    End Function

    Public Shared Function DateToEpoch(DateTime As Date) As String

        Try
            Dim x As Int64
            x = Now.Subtract(CDate("1/1/1970 00:00:00")).TotalMilliseconds
            Return CStr(x)
        Catch ex As Exception
            Return -1
        End Try

    End Function

    Friend Shared Function StripPhone(Text As String) As String

        Return Right(Text, Len(Text) - 1)

    End Function

    Public Shared Function FileToText(Path As String) As String

        Dim objReader As System.IO.StreamReader = Nothing
        Dim strContent As String = ""

        Try
            objReader = New System.IO.StreamReader(Path)
            strContent = objReader.ReadToEnd
        Catch ex As Exception
            Threading.Thread.Sleep(2000)
            FileToText(Path)
        Finally
            If Not objReader Is Nothing Then
                objReader.Close()
            End If
        End Try

        Return strContent

    End Function



End Class
